package gui.utils;

import java.awt.Color;
import java.awt.GradientPaint;
import java.awt.Graphics;
import java.awt.Graphics2D;
import java.awt.Paint;

import javax.swing.JPanel;
import javax.swing.UIManager;

public class JRoundDegradePanel extends JPanel{

	public static int HORIZONTAL = 0;
	public static int DIAGONAL = 1;
	public static int CARRE = 2;
	public static int ROUND = 3;

	private Color color1;
	private Color color2;
	private int degraded;
	private int border;

	public JRoundDegradePanel(){

		color1 = Color.BLACK;
		color2 = Color.WHITE;
		degraded = HORIZONTAL;
		border = ROUND;

	}


	public  JRoundDegradePanel(int degraded,int border){
		color1 = Color.BLACK;
		color2 = Color.WHITE;
		this.degraded = degraded;
		this.border = CARRE;

	}

	public void paintComponent(Graphics g) {
		super.paintComponent(g);


		Color control = UIManager.getColor("control");
		int width = getWidth();
		int height = getHeight();

		if (degraded == DIAGONAL){
			Graphics2D g2 = (Graphics2D) g;
			Paint storedPaint = g2.getPaint();
			g2.setPaint(new GradientPaint(500,700, color1,
					(2 * getWidth() / 3), 1000,color2));
			g2.fillRect(0, 0, width, height);
			g2.setPaint(storedPaint);
		}
		else{

			Graphics2D g2 = (Graphics2D) g;
			Paint storedPaint = g2.getPaint();

			g2.setPaint(new GradientPaint(0,(getHeight()/10), color1,
					0, getHeight(), color2));
			g2.fillRoundRect(0,-10, width, height+10,25,25);
			g2.setPaint(storedPaint);
		}
	}

	/**
	 * @return the color1
	 */
	public Color getColor1() {
		return color1;
	}

	/**
	 * @return the color2
	 */
	public Color getColor2() {
		return color2;
	}

	/**
	 * @param color1 the color1 to set
	 */
	public void setColor1(Color color1) {
		this.color1 = color1;
	}

	/**
	 * @param color2 the color2 to set
	 */
	public void setColor2(Color color2) {
		this.color2 = color2;
	}

}
